home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 104_01 / c6.c < prev    next >
Text File  |  1980-01-01  |  4KB  |  211 lines

  1. /*      >>>>>> start of cc6 <<<<<<      */
  2. #ifndef    TRUE    /* see if need include file */
  3. #include <C.DEF>
  4. #endif
  5.  
  6. heir7(lval,status)
  7. int lval[];
  8. int *status;
  9. {
  10.     int k,lval2[lvalsize];
  11.     k=heir8(lval,status);
  12.     blanks();
  13.     if (!streq(line+lptr,">>") &&
  14.         !streq(line+lptr,"<<")) return k;
  15.     rvalue(lval,k);
  16.     while(1) {
  17.         if (match(">>")) {
  18.             push();
  19.             k=heir8(lval2);
  20.             rvalue(lval2,k);
  21.             asr();
  22.             *status=FALSE;
  23.             }
  24.         else if (match("<<")) {
  25.             push();
  26.             k=heir8(lval2);
  27.             rvalue(lval2,k);
  28.             asl();
  29.             *status=FALSE;
  30.             }
  31.         else return 0;
  32.         }
  33.     }
  34. heir8(lval,status)
  35. int lval[];
  36. int *status;
  37. {
  38.     int k,lval2[lvalsize];
  39.     k=heir9(lval,status);
  40.     blanks();
  41.     if ((ch() != '+' && ch() != '-') || nch() == '=') return k;
  42.     rvalue(lval,k);
  43.     while(1) { 
  44.         switch(ch()) {
  45.  
  46.             /* add last item to next item */
  47.             case '+' :
  48.                 push();
  49.                 gch();
  50.                 k=heir9(lval2,status);
  51.                 rvalue(lval2,k);
  52.                 size_adjust(lval);
  53.                 add();
  54.                 *status=FALSE;
  55.                 break;
  56.  
  57.             /* subtract next item from current item */
  58.             case '-' :
  59.                 push();
  60.                 gch();
  61.                 k=heir9(lval2,status);
  62.                 rvalue(lval2,k);
  63.                 size_adjust(lval);
  64.                 sub();
  65.                 *status=FALSE;
  66.                 break;
  67.  
  68.             /* operator not "+" or "-" */
  69.             default :
  70.                 return 0;
  71.             }
  72.         }
  73.     }
  74. heir9(lval,status)
  75. int lval[];
  76. int *status;
  77. {
  78.     int k,lval2[lvalsize],temp;
  79.  
  80.     temp=0;
  81.     k=heir10(lval,&temp,status);
  82.     blanks();
  83.     if ((ch() != '*' && ch()!='/' && ch() != '%') 
  84.         || nch() == '=') return k;
  85.     rvalue(lval,k);
  86.     while(1) {
  87.         if (match("*")) {
  88.             push();
  89.             k=heir10(lval2,&temp,status);
  90.             rvalue(lval2,k);
  91.             mult();
  92.             *status=FALSE;
  93.             }
  94.         else if (match("/")) {
  95.             push();
  96.             k=heir10(lval2,&temp,status);
  97.             rvalue(lval2,k);
  98.             div();
  99.             *status=FALSE;
  100.             }
  101.         else if (match("%")) {
  102.             push();
  103.             k=heir10(lval2,&temp,status);
  104.             rvalue(lval2,k);
  105.             mod();
  106.             *status=FALSE;
  107.             }
  108.         else return 0;
  109.         }
  110.     }
  111. heir10(lval,count,status)
  112. int lval[];
  113. int *count;
  114. int *status;
  115. {
  116.     int k,lval2[lvalsize];
  117.     char *ptr,flag;
  118.  
  119.     if(match("++")) {
  120.         if (!(k=heir10(lval,count,status))) {
  121.             needlval();
  122.             return LOADED;
  123.             }
  124.         lval[1] += *count;
  125.         address(lval,k);
  126.         pre_inc(lval);
  127.         return LOADED;
  128.         }
  129.     else if (match("--")) {
  130.         if (!(k=heir10(lval,count,status))) {
  131.             needlval();
  132.             return LOADED;
  133.             }
  134.         lval[1] += *count;
  135.         address(lval,k);
  136.         pre_dec(lval);
  137.         *status=TRUE;
  138.         return LOADED;
  139.         }
  140.     else if (match("-")) {
  141.         if (isdigit(nch())) constant();
  142.         else {
  143.             k=heir10(lval,count,status);
  144.             rvalue(lval,k);
  145.             neg();
  146.             *status=TRUE;
  147.             }
  148.         return LOADED;
  149.         }    
  150.     else if (match("*")) {
  151.         ++*count;
  152.         k=heir10(lval,count,status);
  153.         rvalue(lval,k);
  154.         lval[1] += *count;
  155.         *count=0;
  156.         *status=FALSE;
  157.         return ADDRESS;
  158.         }
  159.     else if (match("&")) {
  160.         k=heir10(lval,count,status);
  161.         *status=FALSE;
  162.         if (k == 0 || lval[0]) {
  163.             error("illegal address");
  164.             return LOADED;
  165.             }
  166.         else if (lval[1]) return LOADED;
  167.             else {
  168.                 immed();
  169.                 outstr(ptr=lval[0]);
  170.                 nl();
  171.                 return LOADED;
  172.                 }
  173.         }
  174.     else if (match("!")) {
  175.         rvalue(lval,heir10(lval,count,status));
  176.         nlogical();
  177.         *status=TRUE;
  178.         return LOADED;
  179.         }
  180.     else {
  181.         k=heir11(lval,status);
  182.         movmem(lval,lval2,lvalsize*2);
  183.         lval2[1] += *count;
  184.         if (match("++")) {
  185.             if(k == LOADED) {
  186.                 needlval();
  187.                 return LOADED;
  188.                 }
  189.             address(lval,k);
  190.             post_inc(lval);
  191.             *status=TRUE;
  192.             return LOADED;
  193.             }
  194.         else if (match("--")) {
  195.             if (k == LOADED) {
  196.                 needlval();
  197.                 return LOADED;
  198.                 }
  199.             address(lval,k);
  200.             post_dec(lval);
  201.             *status=TRUE;
  202.             return LOADED;
  203.             }
  204.         else return k;
  205.         }
  206.     }
  207. k;
  208.         }
  209.     }
  210. 
  211.         else return k;